function Util(){

    this.getUrlParam = function(k){
        var reg = new RegExp("(^|&)"+ k +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) {
            return decodeURI(r[2]);
        }
        return null;
    };

    this.storage = function(type){
        var storage = window.localStorage;
        if('session' == type){
            storage = window.sessionStorage;
        }

        return {
            get : function(k){
                var v = storage.getItem(k);
                if(null == v){
                    return v;
                }
                try{
                    return JSON.parse(v);
                }catch(e){
                    return v;
                }
            },
            put : function (k,v) {
                if(typeof(v) == "object"){
                    v = JSON.stringify(v);
                }
                storage.setItem(k,v);
            },
            remove:function(k){
                storage.removeItem(k);
            },
            clear:function(){
                storage.clear();
            }
        };
    };

    this.shortStr = function(src,length,mark){
        if(src.length > length){
            return src.substr(0,length).concat(mark);
        }
        return src;
    };

    this.appId = function(){
        // let appId = this.storage().get('appId');
        // if(!appId){
        //     appId =
        // }

        return this.getUrlParam('appid');;
    };
};

module.exports = new Util();